﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using Baza.EF.BLL;
using Baza.EF.DAL;


namespace Pep_3014_3070_Desktop
{
    public partial class RemoveOwner : Form
    {
        public RemoveOwner()
        {
            InitializeComponent();
        }

        private void RemoveOwner_Load(object sender, EventArgs e)
        {
            cmbIznajmljivac.DataSource = DAIznajmljivaciApartmani.SelectOwners();
            cmbIznajmljivac.DisplayMember = "FirstName";

        }

        private void cmbIznajmljivac_Format(object sender, ListControlConvertEventArgs e)
        {
            string lastname = ((Owners)e.ListItem).FirstName;
            string firstname = ((Owners)e.ListItem).LastName;
            e.Value = lastname + " " + firstname;
        }

        private void btnOdustani_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnSpremi_Click(object sender, EventArgs e)
        {
            Owners owner = (Owners)cmbIznajmljivac.SelectedItem;
            DAIznajmljivaciApartmani.RemoveOwnerBYID(owner.OwnerID);
            MessageBox.Show(Global.GetString("ownerRem_succ"), "Iznajmljivači", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

    }
}
